package cn.tedu.kcircle.detail.adapter.rpc;

import cn.tedu.kcircle.detail.adapter.converter.DetailConverter;
import cn.tedu.kcircle.detail.api.rpc.DetailRpcApi;
import cn.tedu.kcircle.detail.protocol.dto.DetailAddDTO;
import cn.tedu.kcircle.detail.repository.persist.DetailRepository;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class DetailRpcApiImpl implements DetailRpcApi {
    private DetailRepository detailRepository;
    private DetailConverter converter;
    @Override
    public Long saveDetail(DetailAddDTO detailAddDTO) {
        return detailRepository.saveDetail(converter.dto2Model(detailAddDTO));
    }

    @Override
    public int deleteDetailById(Long id) {
        return detailRepository.deleteById(id);
    }

    @Override
    public String getDetailById(Long id) {
        return detailRepository.getDetailById(id);
    }
}
